package com.example.foobar.dao.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.foobar.dao.service.ImsPzGuanhuaiTrackDaoService;
import com.example.foobar.dto.DABaseDTO;
import com.example.foobar.entity.DaNewCommerCount;
import com.example.foobar.entity.ImsPzGuanhuaiTrack;
import com.example.foobar.mapper.ImsPzGuanhuaiTrackMapper;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *  服务实现类
 *
 * @author 郑英奔
 * @since 2021-05-31
 */
@Slf4j
@Service
@DS("db1")
public class ImsPzGuanhuaiTrackDaoServiceImpl extends BaseServiceImpl<ImsPzGuanhuaiTrackMapper, ImsPzGuanhuaiTrack> implements ImsPzGuanhuaiTrackDaoService {

    @Autowired
    private ImsPzGuanhuaiTrackMapper imsPzGuanhuaiTrackMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveImsPzGuanhuaiTrack(ImsPzGuanhuaiTrack imsPzGuanhuaiTrack) throws Exception {
        return super.save(imsPzGuanhuaiTrack);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateImsPzGuanhuaiTrack(ImsPzGuanhuaiTrack imsPzGuanhuaiTrack) throws Exception {
        return super.updateById(imsPzGuanhuaiTrack);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteImsPzGuanhuaiTrack(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public Integer selectCount(LambdaQueryWrapper<ImsPzGuanhuaiTrack> imsPzGuanhuaiTrackLambdaQueryWrapper) {
        return imsPzGuanhuaiTrackMapper.selectCount(imsPzGuanhuaiTrackLambdaQueryWrapper);
    }

    @Override
    public List<DABaseDTO> getActiveDataByOfficialAccountIdAndDataRange(Map<String, Object> params) {
        return imsPzGuanhuaiTrackMapper.getActiveDataByOfficialAccountIdAndDataRange(params);
    }

    @Override
    public int getSubscribeCount(Map<String, Object> params) {
        return imsPzGuanhuaiTrackMapper.getSubscribeCount(params);
    }

    @Override
    public int getUnsubscribeCount(Map<String, Object> params) {
        return imsPzGuanhuaiTrackMapper.getUnsubscribeCount(params);
    }

    @Override
    public Date minDateInDb() {
        Date date = imsPzGuanhuaiTrackMapper.minDateInDb("date");
        return date;
    }
}
